<?php
declare(strict_types = 1);
namespace app\admin\middleware;

use think\Request;
use \liliuwei\think\Jump;
use think\facade\Session;
class CheckAdmin
{

    //use \app\common\traits\JumpTrait;
    
    public function handle(Request $request, \Closure $next)
    {
        $adminId = Session::get('admin.id');
        if(empty($adminId) && !preg_match('/login/i',$request->pathinfo())){

            return redirect(__url('admin/login/index'));
        }

        return $next($request);
    }
    public function end(\think\Response $response)
    {
        // 回调行为
    }
}